import useWidget from '@/hooks/useWidget'
import useData from './useData'
import useFields from './useFields'
import useMeta from './useMeta'

function useDataCfg(widgetId) {
  const { currentWidget } = useWidget(widgetId)
  const data = currentWidget?.status?.data || []
  const queryFields = currentWidget?.query?.queryFields || {}

  const _meta = useMeta(queryFields)
  const _fields = useFields(queryFields)
  const _data = useData(data, _meta)
  return { meta: _meta, fields: _fields, data: _data }
}

export default useDataCfg
